package com.itheima.bean;

import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;

public class MyImportSelector implements ImportSelector {

    //各种条件的判定，判定完毕后，决定是否装在指定的bean
    //ImportSelector，可以做动态的bean加载控制  如

    @Override
    public String[] selectImports(AnnotationMetadata annotationMetadata) {


//        System.out.println("提示"+annotationMetadata.getClassName());
//
//        System.out.println(annotationMetadata.hasAnnotation("org.springframework.context.annotation.Configuration"));
//        return new String[]{"com.itheima.bean.Dog"};

        boolean flag = annotationMetadata.hasAnnotation("org.springframework.context.annotation.Configuration");
        if(flag){
            return new String[]{"com.itheima.bean.Dog"};
        }else{
            return new String[]{"com.itheima.bean.Cat"};
        }


    }
}
